#include<stdio.h>
#include<algorithm>
using namespace std;
int hi[200005];
void qsort(int le, int ri)
{
	int i = le, j = ri, mid = hi[(le + ri) / 2];
	while (i <= j)
	{
		while (hi[i] < mid)
		{
			i++;
		}
		while (hi[j] > mid)
		{
			j--;
		}
		if (i <= j)
		{
			swap(hi[i], hi[j]);
			i++;
			j--;
		}
	}
	if (le < j)
	{
		qsort(le, j);
	}
	if (i < ri)
	{
		qsort(i, ri);
	}
}
int main()
{
	int n, b;
	scanf("%d %d", &n, &b);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &hi[i]);
	}
	qsort(1, n);
	int sum = 0, i = 1, js = 0;
	while (sum < b)
	{
		sum += hi[i];
		i++;
		js++;
	}
	printf("%d", js-1);

	return 0;
}
